﻿using DX;
using DX.Behaviors;
using DX.ViewModels;
using DX.Views;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Drawing;
using System.Windows.Forms;
using Tools.ControlHandlers;

namespace Tools.Views
{
    public partial class OfficeMainForm : ViewForm, ILoadPluginsBehavior
    {
        public OfficeMainForm()
        {
            InitializeComponent();
       
 
        }
        OfficeTabPluginHandler handler;
        protected override void OnAttachView(IView view, IViewModel viewModel)
        {
            base.OnAttachView(view, viewModel);
            IRouterFactory routFactory = this.ViewModel.Context.ServiceProvider.GetRequiredService<IRouterFactory>();
            handler = new OfficeTabPluginHandler(routFactory,  tabControl1 , this.contextMenuStrip1);
            toolStripSplitButton1.Command = ViewModel.TryCloseCommand;
        }
    
        void ILoadPluginsBehavior.AddPlugins(PluginProfile pluginProfile, EventHandler click)
        {
            if (pluginProfile == null) return;
            EventHandler tmpclick =   handler.Create(pluginProfile, click);
            toolStripMenuItem1.DropDownItems.Add(pluginProfile.Title, null, tmpclick);

        }
    


    }
}
